{template user/header}
    <div class="main">
		<dl class="dldt1">
        	<dt>
                <strong><a href="javascript:;" class="hover">可用优惠券({count($allow_lists)})</a></strong>
                <strong><a href="javascript:;">不可用优惠券({count($not_allow_lists)})</a></strong>
            </dt>
            <dd>
            	<div class="swiper-container">
                    <div class="swiper-wrapper">
                        <div class="swiper-slide">
                        {if $allow_lists}
                        	<ul class="juan" id="allow_coupons">
                            {loop $allow_lists $coupons}
								<li data-value='{$coupons[id]}' {if $norder_keys[coupons_id] == $coupons[id]}class="hover"{/if}>
									<strong>优惠券金额：{MONUNIT}{$coupons[value]}</strong>
									<p>
										使用规则：{$coupons[name]}<br />
										使用期限：{mdate($coupons[start_time], 'Y-m-d')}~{mdate($coupons[end_time], 'Y-m-d')}
									</p>
								</li>
                            {/loop}
							</ul>
							<div class="mar15">
								<input type="button" value="使用此优惠券" name="dosubmit" class="btnBlue">
							</div>
                        {else}
                            <div class="none"><img src="{THEME_PATH}img/bg_2.png" /><p>您还没有相关的优惠券</p></div>
                        {/if}
                        </div>
                        <div class="swiper-slide">
                            {if $not_allow_lists}
                            <ul class="juan">
                                {loop $not_allow_lists $coupons}
                                <li class="disabled">
                                    <strong>优惠券金额：{MONUNIT}{$coupons[value]}</strong>
                                    <p>
                                        使用规则：{$coupons[name]}<br />
                                        使用期限：{mdate($coupons[start_time], 'Y-m-d')}~{mdate($coupons[end_time], 'Y-m-d')}
                                    </p>
                                </li>
                                {/loop}
                            </ul>
                            {else}
                            <div class="none"><img src="{THEME_PATH}img/bg_2.png" /><p>您还没有相关的优惠券</p></div>
                            {/if}
                        </div>
                    </div>
                </div>
            </dd>
        </dl>
    </div>
    <script src="{THEME_PATH}js/swiper.min.js"></script>
    <script type="text/javascript">
    setTitle('选择优惠券');
    var tabsSwiper = new Swiper('.swiper-container',{
        speed:500,
        onSlideChangeStart: function(){
            $(".dldt1 strong a").removeClass('hover');
            $(".dldt1 strong a").eq(tabsSwiper.activeIndex).addClass('hover');
        }
    });
    $(".dldt1 strong").on('touchstart mousedown',function(e){
        e.preventDefault()
        $(".dldt1 strong a").removeClass('hover');
        $(this).find("a").addClass('hover');
        tabsSwiper.slideTo($(this).index());
    });
    $(".dldt1 strong").click(function(e){
        e.preventDefault();
    });
    $(function(){
        $("#allow_coupons li").click(function(){
            $("#allow_coupons li").removeClass("hover");
            $(this).addClass("hover");
        });
        $("input[name=dosubmit]").click(function() {
            if($('#allow_coupons li[class=hover]').length == 0) {
                hd_alert('请选择要使用的优惠券');
                return;
            }
            var args = {
                coupons_id : $('#allow_coupons li[class=hover]').attr('data-value'),
            };
            $.post('?m=goods&c=order&a=coupons', args, function(ret) {
                if(ret.status == 1) {
                    window.location.href = '?m=goods&c=order&a=index';
                } else {
                    hd_alert(ret.info);
                }
            }, 'JSON');
        });
    })
    </script>
</body>
</html>